From 6fd3a2834ebdecb6d30be6180142b0f3c1a3396e Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Mon, 2 Sep 2013 13:02:46 +0000 Subject: [PATCH] fix memory leaks in cup, easygps, mapsend, osm, pcx and skyforce exposed by test-all, valgrind and patience. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4588 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/easygps.cc | 11 ++++++++--- gpsbabel/internal_styles.cc | 4 +++- gpsbabel/mapsend.cc | 2 +- gpsbabel/osm.cc | 8 ++++++-- gpsbabel/pcx.cc | 1 + gpsbabel/raymarine.cc | 2 +- gpsbabel/skyforce.cc | 2 ++ gpsbabel/style/cup.style | 4 +++- 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gpsbabel/easygps.cc b/gpsbabel/easygps.cc index 1a25c67a4..34f193f68 100644 --- a/gpsbabel/easygps.cc +++ b/gpsbabel/easygps.cc @@ -106,9 +106,14 @@ data_read(void) } } break; - case 7: - wpt_tmp->icon_descr = gbfgetpstr(file_in); - break; + case 7: { + char* id = gbfgetpstr(file_in); + wpt_tmp->icon_descr = id; + if (id) { + xfree(id); + } + } + break; case 8: /* NULL Terminated (vs. pascal) descr */ wpt_tmp->notes = gbfgetcstr(file_in); break; diff --git a/gpsbabel/internal_styles.cc b/gpsbabel/internal_styles.cc index e007a8840..806959c09 100644 --- a/gpsbabel/internal_styles.cc +++ b/gpsbabel/internal_styles.cc @@ -82,6 +82,8 @@ static char cup[] = "#\n" "# (c) 2006, Robert Lipe, based on sample files by Krzysztof Wojtas\n" "# Reference info: http://www.seeyou.ws/thankyou.php?fname=cup_format.pdf\n" + "# Reference info: http://download.naviter.com/docs/cup_format.pdf\n" + "# Reference info: http://www.keepitsoaring.com/LKSC/Downloads/cup_format.pdf\n" "#\n" "DESCRIPTION See You flight analysis data\n" @@ -98,7 +100,7 @@ static char cup[] = "EPILOGUE -----Related Tasks-----\n" - "IFIELD SHORTNAME,\"\", \"\"%s\"\"\n" + "IFIELD IGNORE,\"\", \"\"%s\"\"\n" "IFIELD SHORTNAME,\"\", \"%s\"\n" "IFIELD CONSTANT,\"\", \"\"\n" "IFIELD LAT_DDMMDIR, \"%f\", \"%08.3f\", \"absolute\"\n" diff --git a/gpsbabel/mapsend.cc b/gpsbabel/mapsend.cc index 6aeb6c50e..6658f9c10 100644 --- a/gpsbabel/mapsend.cc +++ b/gpsbabel/mapsend.cc @@ -360,7 +360,7 @@ mapsend_route_hdr(const route_head* rte) /* route name -- mapsend really seems to want something here.. */ if (r.isEmpty()) { - rname = xstrdup("Route"); + rname = "Route"; } else { rname = rte->rte_name; } diff --git a/gpsbabel/osm.cc b/gpsbabel/osm.cc index 75d31a896..475a598e2 100644 --- a/gpsbabel/osm.cc +++ b/gpsbabel/osm.cc @@ -433,7 +433,7 @@ osm_feature_ikey(const char* key) } -static QString +static char* osm_feature_symbol(const int ikey, const char* value) { char* result; @@ -541,7 +541,11 @@ osm_node_tag(const char* args, const QXmlStreamAttributes* attrv) } wpt->shortname = xstrdup(str); } else if ((ikey = osm_feature_ikey(key)) >= 0) { - wpt->icon_descr = osm_feature_symbol(ikey, value); + char* id = osm_feature_symbol(ikey, value); + wpt->icon_descr = id; + if (id) { + xfree(id); + } } else if (strcmp(key, "note") == 0) { if (wpt->notes) { char* tmp; diff --git a/gpsbabel/pcx.cc b/gpsbabel/pcx.cc index 297460548..e6d619274 100644 --- a/gpsbabel/pcx.cc +++ b/gpsbabel/pcx.cc @@ -392,6 +392,7 @@ pcx_route_hdr(const route_head* rte) if (!cartoexploreur) { gbfprintf(file_out, "\n\nR %s\n", name); } + xfree(name); gbfprintf(file_out, "\n" "H IDNT LATITUDE LONGITUDE DATE TIME ALT DESCRIPTION PROXIMITY SYMBOL ;waypts\n"); } diff --git a/gpsbabel/raymarine.cc b/gpsbabel/raymarine.cc index 6575f5eda..91f4801e3 100644 --- a/gpsbabel/raymarine.cc +++ b/gpsbabel/raymarine.cc @@ -436,7 +436,7 @@ static void enum_route_hdr_cb(const route_head* rte) { is_fatal(rte->rte_waypt_ct > 50, - MYNAME ": Routes with more than 50 points are not supported by Waymarine!"); + MYNAME ": Routes with more than 50 points are not supported by Raymarine!"); } static short_handle diff --git a/gpsbabel/skyforce.cc b/gpsbabel/skyforce.cc index b13a4c7da..50637c933 100644 --- a/gpsbabel/skyforce.cc +++ b/gpsbabel/skyforce.cc @@ -197,6 +197,8 @@ skyforce_waypt_disp_cb(const waypoint* wpt) snprintf(buf + 2, sizeof(buf) - 2, "%03d ", rte_num); } snprintf(buf + 6, sizeof(buf) - 6, "%03d %-9s ", wpt_num, name); + + xfree(name); } diff --git a/gpsbabel/style/cup.style b/gpsbabel/style/cup.style index 7750de4df..2803b760d 100644 --- a/gpsbabel/style/cup.style +++ b/gpsbabel/style/cup.style @@ -1,6 +1,8 @@ # # (c) 2006, Robert Lipe, based on sample files by Krzysztof Wojtas # Reference info: http://www.seeyou.ws/thankyou.php?fname=cup_format.pdf +# Reference info: http://download.naviter.com/docs/cup_format.pdf +# Reference info: http://www.keepitsoaring.com/LKSC/Downloads/cup_format.pdf # DESCRIPTION See You flight analysis data @@ -17,7 +19,7 @@ PROLOGUE name,code,country,lat,lon,elev,style,rwdir,rwlen,freq,desc EPILOGUE -----Related Tasks----- -IFIELD SHORTNAME,"", ""%s"" +IFIELD IGNORE,"", ""%s"" IFIELD SHORTNAME,"", "%s" IFIELD CONSTANT,"", "" IFIELD LAT_DDMMDIR, "%f", "%08.3f", "absolute" -- 2.30.2